#!/usr/bin/php
<?php

if (php_sapi_name() !== "cli") exit;

$autoLoadPaths = [
    __DIR__ . '/vendor/autoload.php', 
    __DIR__ . '/../vendor/autoload.php', 
    __DIR__ . '/../../../autoload.php'
];

foreach($autoLoadPaths as $autoloader) {
    if( file_exists($autoloader) ) {
        require $autoloader;
        break;
    }
}

use Rudra\Cli\ConsoleFacade as Cli;
use Rudra\Markdown\Commands\ConsoleCommand;
use Rudra\Markdown\Commands\DocumentationCommand;

parse_str(implode('&', array_slice($argv, 1)), $inputArgs);

Cli::addCommand("docs", [DocumentationCommand::class]);
Cli::addCommand("help", [ConsoleCommand::class]);
Cli::invoke($inputArgs);
